home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Tools / Utility / DisplayNameRegistry 950412 / Src / SetFontInfoDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-27  |  2.7 KB  |  106 lines  |  [TEXT/MPCC]

  1. /*                                    SetFontDialog.c                                */
  2. /*
  3.  * SetFontDialog.c
  4.  * Copyright © 1993-94 Apple Computer Inc. All rights reserved.
  5.  */
  6. #define CountMenuItems    CountMItems    /* TEMP for MetroWerks Interface Library    */
  7.  
  8. #include "DisplayNameRegistry.h"
  9.  
  10. enum {
  11.     kDialogOKButton = 1,
  12.     kDialogCancelButton,
  13.     kDialogFontNamePopup,
  14.     kDialogFontSizePopup
  15. };
  16.  
  17. Boolean
  18. SetFontInfoDialog(
  19.         register BrowserPtr        browserPtr
  20.     )
  21. {
  22.         DialogPtr                theDialog;
  23.         short                    itemType;
  24.         Rect                    itemRect;
  25.         short                    i;
  26.         short                    nMenuItems;
  27.         short                    itemHit;
  28.         long                    fontSize;
  29.         Str255                    fontSizeText;
  30.         Str255                    work;
  31.         GrafPtr                    savePort;
  32.         MenuHandle                fontNameMenu;
  33.         MenuHandle                fontSizeMenu;
  34.         ControlHandle            fontNamePopup;
  35.         ControlHandle            fontSizePopup;
  36.         
  37.         itemHit = kDialogCancelButton;
  38.         GetPort(&savePort);
  39.         fontNameMenu = GetMenu(MENU_FontName);
  40.         AppendResMenu(fontNameMenu, 'FONT');
  41.         fontSizeMenu = GetMenu(MENU_FontSize);
  42.         theDialog = GetNewDialog(DLOG_SetFontInfo, NULL, (WindowPtr) -1L);
  43.         if (theDialog != NULL) {
  44.             SetPort(theDialog);
  45.             GetDialogItem(
  46.                 theDialog,
  47.                 kDialogFontNamePopup,
  48.                 &itemType,
  49.                 (Handle *) &fontNamePopup,
  50.                 &itemRect
  51.             );
  52.             GetDialogItem(
  53.                 theDialog,
  54.                 kDialogFontSizePopup,
  55.                 &itemType,
  56.                 (Handle *) &fontSizePopup,
  57.                 &itemRect
  58.             );
  59.             SetDialogDefaultItem(theDialog, kDialogOKButton);
  60.             SetDialogCancelItem(theDialog, kDialogCancelButton);
  61.             /*
  62.              * Initialize the font name popup menu
  63.              */
  64.             nMenuItems = CountMenuItems(fontNameMenu);
  65.             for (i = 1; i <= nMenuItems; i++) {
  66.                 GetMenuItemText(fontNameMenu, i, work);
  67.                 if (EqualString(work, BROWSER.fontNameText, FALSE, FALSE))
  68.                     break;
  69.             }
  70.             SetControlValue(fontNamePopup, (i <= nMenuItems) ? i : 1);
  71.             /*
  72.              * Initialize the font size popup menu
  73.              */
  74.             NumToString(BROWSER.fontSize, fontSizeText);
  75.             nMenuItems = CountMenuItems(fontSizeMenu);
  76.             for (i = 1; i <= nMenuItems; i++) {
  77.                 GetMenuItemText(fontSizeMenu, i, work);
  78.                 if (EqualString(work, fontSizeText, FALSE, FALSE))
  79.                     break;
  80.             }
  81.             SetControlValue(fontSizePopup, (i <= nMenuItems) ? i : 1);
  82.             ShowWindow(theDialog);
  83.             do {
  84.                 ModalDialog(NULL, &itemHit);
  85.             } while (itemHit != kDialogOKButton && itemHit != kDialogCancelButton);
  86.             if (itemHit == kDialogOKButton) {
  87.                 GetMenuItemText(
  88.                     fontNameMenu,
  89.                     GetControlValue(fontNamePopup),
  90.                     BROWSER.fontNameText
  91.                 );
  92.                 GetFNum(BROWSER.fontNameText, &BROWSER.fontNumber);
  93.                 GetMenuItemText(
  94.                     fontSizeMenu,
  95.                     GetControlValue(fontSizePopup),
  96.                     fontSizeText
  97.                 );
  98.                 StringToNum(fontSizeText, &fontSize);
  99.                 BROWSER.fontSize = fontSize;
  100.             }                
  101.             DisposeDialog(theDialog);
  102.         }
  103.         SetPort(savePort);
  104.         return (itemHit == kDialogOKButton);
  105. }
  106.